# \src\schemas\sys_dict_table.py
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime


class SysDictTableBase(BaseModel):
    dict_value: str = Field(..., max_length=36, description="值")
    dict_code: str = Field(..., max_length=36, description="字典代码")
    dict_text: str = Field(..., max_length=36, description="字典名称")
    dict_disabled: str = Field(..., max_length=128, description="禁用")
    table_name: str = Field(..., max_length=64, description="表名")
    conditional: str = Field(..., max_length=1024, description="条件/排序语句")
    dict_id: str = Field(..., max_length=36, description="字典ID")
    enabled: bool = Field(True, description="可用")
    dict_root: bool = Field(False, description="是否需要跟目录")
    deletion_mark: bool = False
    deletion_reason: Optional[str] = None
    deletion_date: Optional[datetime] = None
    deletion_by: Optional[str] = None
    create_date: Optional[datetime] = None
    creator_by: Optional[str] = None
    last_updated_date: Optional[datetime] = None
    last_updated_by: Optional[str] = None
    description: Optional[str] = Field(None, max_length=128, description="说明描述")


class SysDictTableCreate(SysDictTableBase):
    api_id: Optional[str] = Field(None, max_length=36, description="API主键，用于关联其他系统")


class SysDictTable(SysDictTableBase):
    id: str
    api_id: str | None = None

    class Config:
        from_attributes = True
